home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / perl5 / CGI::Push.z / CGI::Push
Encoding:
Text File  |  1998-10-30  |  6.7 KB  |  199 lines

  1.  
  2.  
  3.  
  4. CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))                                                      CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      CGI::Push - Simple Interface to Server Push
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.          use CGI::Push qw(:standard);
  13.  
  14.          do_push(-next_page=>\&next_page,
  15.                  -last_page=>\&last_page,
  16.                  -delay=>0.5);
  17.  
  18.          sub next_page {
  19.              my($q,$counter) = @_;
  20.              return undef if $counter >= 10;
  21.              return start_html('Test'),
  22.                     h1('Visible'),"\n",
  23.                     "This page has been called ", strong($counter)," times",
  24.                     end_html();
  25.            }
  26.  
  27.           sub last_page {
  28.               my($q,$counter) = @_;
  29.               return start_html('Done'),
  30.                      h1('Finished'),
  31.                      strong($counter),' iterations.',
  32.                      end_html;
  33.           }
  34.  
  35.  
  36. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  37.      CGI::Push is a subclass of the CGI object created by CGI.pm.  It is
  38.      specialized for server push operations, which allow you to create
  39.      animated pages whose content changes at regular intervals.
  40.  
  41.      You provide CGI::Push with a pointer to a subroutine that will draw one
  42.      page.  Every time your subroutine is called, it generates a new page.
  43.      The contents of the page will be transmitted to the browser in such a way
  44.      that it will replace what was there beforehand.  The technique will work
  45.      with HTML pages as well as with graphics files, allowing you to create
  46.      animated GIFs.
  47.  
  48. UUUUSSSSIIIINNNNGGGG CCCCGGGGIIII::::::::PPPPuuuusssshhhh
  49.      CGI::Push adds one new method to the standard CGI suite, _d_o__p_u_s_h().  When
  50.      you call this method, you pass it a reference to a subroutine that is
  51.      responsible for drawing each new page, an interval delay, and an optional
  52.      subroutine for drawing the last page.  Other optional parameters include
  53.      most of those recognized by the CGI _h_e_a_d_e_r() method.
  54.  
  55.      You may call _d_o__p_u_s_h() in the object oriented manner or not, as you
  56.      prefer:
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))                                                      CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))
  71.  
  72.  
  73.  
  74.          use CGI::Push;
  75.          $q = new CGI::Push;
  76.          $q->do_push(-next_page=>\&draw_a_page);
  77.  
  78.              -or-
  79.  
  80.          use CGI::Push qw(:standard);
  81.          do_push(-next_page=>\&draw_a_page);
  82.  
  83.      Parameters are as follows:
  84.  
  85.      -next_page
  86.  
  87.              do_push(-next_page=>\&my_draw_routine);
  88.  
  89.          This required parameter points to a reference to a subroutine
  90.          responsible for drawing each new page.  The subroutine should expect
  91.          two parameters consisting of the CGI object and a counter indicating
  92.          the number of times the subroutine has been called.  It should return
  93.          the contents of the page as an aaaarrrrrrrraaaayyyy of one or more items to print.
  94.          It can return a false value (or an empty array) in order to abort the
  95.          redrawing loop and print out the final page (if any)
  96.  
  97.              sub my_draw_routine {
  98.                  my($q,$counter) = @_;
  99.                  return undef if $counter > 100;
  100.                  return start_html('testing'),
  101.                         h1('testing'),
  102.                         "This page called $counter times";
  103.              }
  104.  
  105.  
  106.      -last_page
  107.          This optional parameter points to a reference to the subroutine
  108.          responsible for drawing the last page of the series.  It is called
  109.          after the -next_page routine returns a false value.  The subroutine
  110.          itself should have exactly the same calling conventions as the
  111.          -next_page routine.
  112.  
  113.      -type
  114.          This optional parameter indicates the content type of each page.  It
  115.          defaults to "text/html".  Currently, server push of heterogeneous
  116.          document types is not supported.
  117.  
  118.      -delay
  119.          This indicates the delay, in seconds, between frames.  Smaller delays
  120.          refresh the page faster.  Fractional values are allowed.
  121.  
  122.          IIIIffff nnnnooootttt ssssppppeeeecccciiiiffffiiiieeeedddd,,,, ----ddddeeeellllaaaayyyy wwwwiiiillllllll ddddeeeeffffaaaauuuulllltttt ttttoooo 1111 sssseeeeccccoooonnnndddd
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))                                                      CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))
  137.  
  138.  
  139.  
  140.      -cookie, -target, -expires
  141.          These have the same meaning as the like-named parameters in
  142.          _C_G_I::_h_e_a_d_e_r().
  143.  
  144. IIIINNNNSSSSTTTTAAAALLLLLLLLIIIINNNNGGGG CCCCGGGGIIII::::::::PPPPuuuusssshhhh SSSSCCCCRRRRIIIIPPPPTTTTSSSS
  145.      Server push scripts mmmmuuuusssstttt be installed as no-parsed-header (NPH) scripts
  146.      in order to work correctly.  On Unix systems, this is most often
  147.      accomplished by prefixing the script's name with "nph-". Recognition of
  148.      NPH scripts happens automatically with WebSTAR and Microsoft IIS.  Users
  149.      of other servers should see their documentation for help.
  150.  
  151. CCCCAAAAVVVVEEEEAAAATTTTSSSS
  152.      This is a new module.  It hasn't been extensively tested.
  153.  
  154. AAAAUUUUTTTTHHHHOOOORRRR IIIINNNNFFFFOOOORRRRMMMMAAAATTTTIIIIOOOONNNN
  155.      be used and modified freely, but I do request that this copyright notice
  156.      remain attached to the file.  You may modify this module as you wish, but
  157.      if you redistribute a modified version, please attach a note listing the
  158.      modifications you have made.
  159.  
  160.      Address bug reports and comments to:  lstein@genome.wi.mit.edu
  161.  
  162. BBBBUUUUGGGGSSSS
  163.      This section intentionally left blank.
  164.  
  165. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  166.      the _C_G_I::_C_a_r_p manpage, the _C_G_I manpage
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.